package com.rosiminc.pm.game.tiles;

import com.rosiminc.pm.game.Tile;

/**
 * This class represents a factory to generate game board tiles.
 * 
 * @author Shymon
 * 
 */
public class GameTileFactory {

	/**
	 * This private constructor disables instantiation.
	 */
	private GameTileFactory() {
	}

	/**
	 * This method creates a game board tile according to its position, tile and
	 * type.
	 * 
	 * @param row
	 *            the row
	 * @param col
	 *            the column
	 * @param tile
	 *            the pipe tile
	 * @param type
	 *            the tile type
	 * @return the generated game tile
	 */
	public static GameBoardTile getTile(int row, int col, Tile tile,
			TileType type) {
		
		//Prevent flip tiles from being invisible
		if(tile.getNumSides()==0)
			type = TileType.BLOCK;
		
		switch (type) {
		case ROTATE:
			return new RotateTile(row, col, tile);
		case FLIP:
			return new FlipTile(row, col, tile);
		case BLOCK:
			return new BlockTile(row, col, tile);
		default:
			throw new IllegalArgumentException("Unsupported tile type");
		}
	}
}
